<?php

namespace App\Services\Admin;

use App\Models\UserRankExp as UserRankExpModels;
use App\Models\UserRank as UserRankModels;

class UserRankExp extends Base
{
    public static function index()
    {
        return UserRankExpModels::with(['user'])->whereHas('user',function($query){
            $where = [];
            if(request()->sear_value != ''){
                $where[] = ['nickname','like',request()->sear_value];
                $where[] = ['phone','like',request()->sear_value,'OR'];
            }
            $query->where($where);
        })->orderBy('id','desc');
    }

    //查询等级
    public static function level($id = 0)
    {
        $where = [];

        if(!empty($id))$where[] = ['id',$id];

        return UserRankModels::where($where)->select('id','rank_name')->get();
    }
}
